using System;
using System.Collections.Generic;
using System.Text;
using Common.Shared.Design;
using System.ComponentModel;

namespace Common.Shared.Xml.Wddx {
	[WddxRoot("binary")]
	public class WddxBinary : WddxPrimitiveDataTypeObject {
		private byte[] _value;

		public WddxBinary ( ) {

		}

		public WddxBinary ( byte[] value ) {
			this.Value = value;
		}

		public new byte[] Value {
			get { return _value; }
			set { _value = value; }
		}

		[WddxText]
		[EditorBrowsable(EditorBrowsableState.Never),Browsable(false)]
		public string ValueString {
			get {
				return Convert.ToBase64String ( this.Value );
			}
			set {
				try {
					this.Value = Convert.FromBase64String ( value );
				} catch ( Exception ex ) {
					throw new WddxException ( ex.Message, ex );
				}
			}
		}
	}
}
